<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.3/themes/default/style.min.css"/>
  <link rel="stylesheet" href="css/common.css">
  <link rel="stylesheet" href="css/search-panel.css">
  <link rel="stylesheet" href="css/scene-viewer.css">
  <link rel="stylesheet" href="css/camera_controls.css">
  <link rel="stylesheet" href="css/toolbar.css">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css">
  <title>Scene Viewer</title>
  <meta charset="utf-8">
</head>

<body>
<!-- UI Markup -->

<div id="sidebar">
  <div id="info">
    Scene Viewer
  </div>

  <div id="tabs">
    <ul>
      <li><a href="#tabs-3">Scene Hierarchy</a></li>
    </ul>
    <div id="tabs-3">
      <div id="sceneHierarchy">
      </div>
    </div>
  </div>
</div>
<div id="contextQueryResultsContainer" class="roundBorder"></div>
<div id="main">
  <div id="cameraControls"></div>
  <div id="sceneToolbar" class="toolbar"></div>
  <div id="canvas">
  </div>
  <div id="console" class="console" style="display:none"></div>
  <div id="instructionsPanel" class="roundBorder grayBackground" style="display:none">
    <span>Instructions</span>
    <p id="instructions"></p>
  </div>
  <div id="loadingModel">
    <span>Loading Model...</span>
  </div>
</div>

<!-- This is ridiculous!!!! We need a system where all dependencies are specified in one place.
     Please revert back to using require.js and get rid of these -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.3/jstree.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.min.js"></script>
<script src="three.min.js"></script>
<script src="STK.bundle.js"></script>
<script>
  function onResize() {
    var tabs = $('#tabs');
    var tabsPanelTotalHeight = $('#sidebar').height() - $('#info').height() - 10;
    tabs.height(tabsPanelTotalHeight);
    var tabsPanelHeight = tabsPanelTotalHeight - tabs.children('ul.ui-tabs-nav').outerHeight() - 10;
    tabs.children('.ui-tabs-panel').height(tabsPanelHeight);
  }

  window.addEventListener('resize', onResize, false);

  $('#tabs').tabs();
  STK.Constants.defaultModelSource = 'models3d';
  var canvas = document.getElementById('canvas');
  var sceneViewer = new STK.SceneViewer({
    container: canvas,
    modelViewerUrl: 'view-model',
    addGround: true,
    loadingIconUrl:  STK.Constants.defaultLoadingIconUrl,
    allowEdit: false,
    editMode: false,
    allowBBoxQuery: false,
    allowSelectMode: true,
    allowConsole: false,
    allowScenePrevNext: false,
    allowHighlightMode: false,
    allowMagicColors: true,
    enableUILog: true,
    showSearchSourceOption: false,
    showInstructions: true,
    contextQueryOptions: { showPriorsViz: true, allowGroupExpansion: true },
    useAmbientOcclusion: true,
    useShadows: true,
    useDatGui: true
  });
  sceneViewer.launch();

  $('#tabs').bind('tabsactivate', function (event, ui) {
    onResize();
    switch (ui.newPanel.attr('id')) {
      case 'tabs-3':
        if (sceneViewer.sceneHierarchy) {
          sceneViewer.sceneHierarchy.onActivate();
        }
        break;
    }
  });

  // Make various components draggable
  $('#instructionsPanel').draggable();
  onResize();
  window.app = sceneViewer; // Hack through to sceneViewer for console debugging
</script>
<link rel="stylesheet" href="css/datgui-light.css">
</body>
</html>
